package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.pojo.Clazz;
import com.itheima.pojo.ClazzQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ClazzMapper {

    @Select("select * from clazz order by update_Time desc")
    List<Clazz> findAll();

    @Insert("insert into clazz(name,room,begin_date,end_date,master_id,subject,create_time,update_time) values(#{name},#{room},#{beginDate},#{endDate},#{masterId},#{subject},#{createTime},#{updateTime})")
    void insert(Clazz clazz);

    @Select("select count(*) from clazz")
    Long count();


    Page<Clazz> pageQuery(ClazzQueryParam clazzQueryParam);

    @Select("select c.*,e.name masterName from clazz c left join emp e on c.master_id = e.id where c.id = #{id}")
    Clazz getById(Integer id);

    @Update("update clazz set name = #{name}, room = #{room}, begin_date = #{beginDate}, end_date = #{endDate}, master_id = #{masterId}, subject = #{subject}, update_time = #{updateTime} where id = #{id}  ")
    void upDate(Clazz clazz);

    @Delete("delete from clazz where id = #{ids}")
    void deleteById(Integer ids);



    @Select("select c.id,c.name,c.room,c.begin_date,c.end_date,c.master_id,c.subject,c.create_time,c.update_time from clazz c")
    List<Clazz> clazzListAll();
}
